version 15
set more off  
clear
capture log close
macro drop _all 

*---------------------------------------------------------------------------*       				
* PROJECT: COMPLAINTS HR	  	    		    							*
* DO FILE: FIGURE 5															*
* AUTHORS: FLORES-MACIAS AND ZARKIN                     					*
* JANUARY 2023              				         						*
*---------------------------------------------------------------------------*       				


*--------------------------------------------------------------------*
* STEP 1: GLOBALS, ADD WORKING DIRECTORY HERE 				 		 *
*--------------------------------------------------------------------*

gl fig ""
gl final ""

*--------------------------------------------------------------------*
* STEP 2: LOAD DATA 				 								 *
*--------------------------------------------------------------------*	

use "$final/ForMatching.dta", clear	

*--------------------------------------------------------------------*
* STEP 3: CREATE HAD OPERATIVO VARIABLE				 				 *
*--------------------------------------------------------------------*	

gen had=1 if yearsop>0 & yearsop!=.
	recode had .=0 if yearsop!=.

*--------------------------------------------------------------------*
* STEP 4: COLLAPSE (MEAN) COMPLAINTS BY TREATMENT AND YEAR		 	 *
*--------------------------------------------------------------------*	
	
collapse(mean) subsetSECFORCESpc [aw=pob], by(had year)
	
*--------------------------------------------------------------------*
* STEP 5: RESHAPE DATA SET TO CREATE FIGURE				   		 	 *
*--------------------------------------------------------------------*	
		
reshape wide sub, i(year) j(had)

*--------------------------------------------------------------------*
* STEP 6: FIGURE 5. AVERAGE SERIOUS HR ABUSE COMPLAINTS AGAINST		 *
* FEDERAL SECURITY FORCES BY TREATMENT STATUS			   		 	 *
*--------------------------------------------------------------------*	
			
twoway (line subsetSECFORCESpc0 year, lcolor(black) lpattern(shortdash) lwidth(medthick)) ///
		(line subsetSECFORCESpc1 year, lpattern(solid) lcolor(black) lwidth(medthick)), ////
		legend(label(1 "Control municipalities") ////
		label(2 "Constabularized municipalities") ///
		r(1) position(6)) ///
		xline(2006, lcolor(gs8) lwidth(medthick) lpattern(solid)) ///
		xlabel(2000(1)2016, labsize(vsmall)) ytitle(Mean serious HR complaints rate) ///
		ylabel(0(.5)3)
	
		graph export "$fig/FIG5.png", replace
		
		* Note: for identical figures install and use the tab1 scheme; ssc install schemepack, replace

